Clover icon

compiler

  1. Project Clover database Mon Jan 2 2023 15:09:37 MST
  2. Package com.google.javascript.rhino

File Token.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
89% of files have more coverage

Code metrics

0
204
1
1
289
216
102
0.5
204
1
102

Classes

Class Line # Actions
Token 52 204 102 103
0.4975609849.8%
 

Contributing tests

This file is covered by 3119 tests. .

Source view

1    /*
2    *
3    * ***** BEGIN LICENSE BLOCK *****
4    * Version: MPL 1.1/GPL 2.0
5    *
6    * The contents of this file are subject to the Mozilla Public License Version
7    * 1.1 (the "License"); you may not use this file except in compliance with
8    * the License. You may obtain a copy of the License at
9    * http://www.mozilla.org/MPL/
10    *
11    * Software distributed under the License is distributed on an "AS IS" basis,
12    * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13    * for the specific language governing rights and limitations under the
14    * License.
15    *
16    * The Original Code is Rhino code, released
17    * May 6, 1999.
18    *
19    * The Initial Developer of the Original Code is
20    * Netscape Communications Corporation.
21    * Portions created by the Initial Developer are Copyright (C) 1997-1999
22    * the Initial Developer. All Rights Reserved.
23    *
24    * Contributor(s):
25    * Roger Lawrence
26    * Mike McCabe
27    * Igor Bukanov
28    * Milen Nankov
29    *
30    * Alternatively, the contents of this file may be used under the terms of
31    * the GNU General Public License Version 2 or later (the "GPL"), in which
32    * case the provisions of the GPL are applicable instead of those above. If
33    * you wish to allow use of your version of this file only under the terms of
34    * the GPL and not to allow others to use your version of this file under the
35    * MPL, indicate your decision by deleting the provisions above and replacing
36    * them with the notice and other provisions required by the GPL. If you do
37    * not delete the provisions above, a recipient may use your version of this
38    * file under either the MPL or the GPL.
39    *
40    * ***** END LICENSE BLOCK ***** */
41   
42    package com.google.javascript.rhino;
43   
44    /**
45    * This class implements the JavaScript scanner.
46    *
47    * It is based on the C source files jsscan.c and jsscan.h
48    * in the jsref package.
49    *
50    */
51   
 
52    public class Token {
53   
54    /**
55    * Token types. These values correspond to JSTokenType values in
56    * jsscan.c.
57    */
58    public final static int
59    ERROR = -1,
60   
61    RETURN = 4,
62    BITOR = 9,
63    BITXOR = 10,
64    BITAND = 11,
65    EQ = 12,
66    NE = 13,
67    LT = 14,
68    LE = 15,
69    GT = 16,
70    GE = 17,
71    LSH = 18,
72    RSH = 19,
73    URSH = 20,
74    ADD = 21,
75    SUB = 22,
76    MUL = 23,
77    DIV = 24,
78    MOD = 25,
79    NOT = 26,
80    BITNOT = 27,
81    POS = 28,
82    NEG = 29,
83    NEW = 30,
84    DELPROP = 31,
85    TYPEOF = 32,
86    GETPROP = 33,
87    GETELEM = 35,
88    CALL = 37,
89    NAME = 38,
90    NUMBER = 39,
91    STRING = 40,
92    NULL = 41,
93    THIS = 42,
94    FALSE = 43,
95    TRUE = 44,
96    SHEQ = 45, // shallow equality (===)
97    SHNE = 46, // shallow inequality (!==)
98    REGEXP = 47,
99    THROW = 49,
100    IN = 51,
101    INSTANCEOF = 52,
102    ARRAYLIT = 63, // array literal
103    OBJECTLIT = 64, // object literal
104   
105    TRY = 77,
106    PARAM_LIST = 83,
107    COMMA = 85, // comma operator
108   
109    ASSIGN = 86, // simple assignment (=)
110    ASSIGN_BITOR = 87, // |=
111    ASSIGN_BITXOR = 88, // ^=
112    ASSIGN_BITAND = 89, // &=
113    ASSIGN_LSH = 90, // <<=
114    ASSIGN_RSH = 91, // >>=
115    ASSIGN_URSH = 92, // >>>=
116    ASSIGN_ADD = 93, // +=
117    ASSIGN_SUB = 94, // -=
118    ASSIGN_MUL = 95, // *=
119    ASSIGN_DIV = 96, // /=
120    ASSIGN_MOD = 97, // %=
121   
122    HOOK = 98, // conditional (?:)
123    OR = 100, // logical or (||)
124    AND = 101, // logical and (&&)
125    INC = 102, // increment (++)
126    DEC = 103, // decrement (--)
127    FUNCTION = 105, // function keyword
128    IF = 108, // if keyword
129    SWITCH = 110, // switch keyword
130    CASE = 111, // case keyword
131    DEFAULT_CASE = 112, // default keyword
132    WHILE = 113, // while keyword
133    DO = 114, // do keyword
134    FOR = 115, // for keyword
135    BREAK = 116, // break keyword
136    CONTINUE = 117, // continue keyword
137    VAR = 118, // var keyword
138    WITH = 119, // with keyword
139    CATCH = 120, // catch keyword
140    VOID = 122, // void keyword
141   
142    EMPTY = 124,
143   
144    BLOCK = 125, // statement block
145    LABEL = 126, // label
146    EXPR_RESULT = 130, // expression statement in scripts
147    SCRIPT = 132, // top-level node for entire script
148   
149    GETTER_DEF = 147,
150    SETTER_DEF = 148,
151   
152    CONST = 149, // JS 1.5 const keyword
153    DEBUGGER = 152,
154   
155    // JSCompiler introduced tokens
156    LABEL_NAME = 153,
157    STRING_KEY = 154, // object literal key
158    CAST = 155,
159   
160    // JSDoc-only tokens
161    ANNOTATION = 300,
162    PIPE = 301,
163    STAR = 302,
164    EOC = 303,
165    QMARK = 304,
166    ELLIPSIS = 305,
167    BANG = 306,
168    EQUALS = 307,
169    LB = 308, // left brackets
170    LC = 309, // left curly braces
171    COLON = 310;
172   
173    // Transitional definitions
174    // TODO(johnlenz): remove these
175    public final static int
176    DEFAULT = DEFAULT_CASE,
177    GET = GETTER_DEF,
178    LP = PARAM_LIST,
179    SET = SETTER_DEF;
180   
 
181  19740 toggle public static String name(int token) {
182  19740 switch (token) {
183  0 case ERROR: return "ERROR";
184  30 case RETURN: return "RETURN";
185  3 case BITOR: return "BITOR";
186  0 case BITXOR: return "BITXOR";
187  0 case BITAND: return "BITAND";
188  9 case EQ: return "EQ";
189  0 case NE: return "NE";
190  12 case LT: return "LT";
191  0 case LE: return "LE";
192  0 case GT: return "GT";
193  0 case GE: return "GE";
194  0 case LSH: return "LSH";
195  0 case RSH: return "RSH";
196  0 case URSH: return "URSH";
197  29 case ADD: return "ADD";
198  6 case SUB: return "SUB";
199  0 case MUL: return "MUL";
200  0 case DIV: return "DIV";
201  0 case MOD: return "MOD";
202  6 case NOT: return "NOT";
203  0 case BITNOT: return "BITNOT";
204  9 case POS: return "POS";
205  2 case NEG: return "NEG";
206  389 case NEW: return "NEW";
207  3 case DELPROP: return "DELPROP";
208  0 case TYPEOF: return "TYPEOF";
209  6485 case GETPROP: return "GETPROP";
210  6 case GETELEM: return "GETELEM";
211  2683 case CALL: return "CALL";
212  7695 case NAME: return "NAME";
213  20 case LABEL_NAME: return "LABEL_NAME";
214  279 case NUMBER: return "NUMBER";
215  86 case STRING: return "STRING";
216  14 case STRING_KEY: return "STRING_KEY";
217  13 case NULL: return "NULL";
218  0 case THIS: return "THIS";
219  0 case FALSE: return "FALSE";
220  7 case TRUE: return "TRUE";
221  0 case SHEQ: return "SHEQ";
222  0 case SHNE: return "SHNE";
223  2 case REGEXP: return "REGEXP";
224  20 case THROW: return "THROW";
225  0 case IN: return "IN";
226  0 case INSTANCEOF: return "INSTANCEOF";
227  14 case ARRAYLIT: return "ARRAYLIT";
228  14 case OBJECTLIT: return "OBJECTLIT";
229  27 case TRY: return "TRY";
230  55 case PARAM_LIST: return "PARAM_LIST";
231  0 case COMMA: return "COMMA";
232  18 case ASSIGN: return "ASSIGN";
233  0 case ASSIGN_BITOR: return "ASSIGN_BITOR";
234  0 case ASSIGN_BITXOR: return "ASSIGN_BITXOR";
235  0 case ASSIGN_BITAND: return "ASSIGN_BITAND";
236  0 case ASSIGN_LSH: return "ASSIGN_LSH";
237  0 case ASSIGN_RSH: return "ASSIGN_RSH";
238  0 case ASSIGN_URSH: return "ASSIGN_URSH";
239  0 case ASSIGN_ADD: return "ASSIGN_ADD";
240  0 case ASSIGN_SUB: return "ASSIGN_SUB";
241  0 case ASSIGN_MUL: return "ASSIGN_MUL";
242  0 case ASSIGN_DIV: return "ASSIGN_DIV";
243  0 case ASSIGN_MOD: return "ASSIGN_MOD";
244  168 case HOOK: return "HOOK";
245  138 case OR: return "OR";
246  60 case AND: return "AND";
247  21 case INC: return "INC";
248  3 case DEC: return "DEC";
249  365 case FUNCTION: return "FUNCTION";
250  24 case IF: return "IF";
251  0 case SWITCH: return "SWITCH";
252  0 case CASE: return "CASE";
253  0 case DEFAULT_CASE: return "DEFAULT_CASE";
254  8 case WHILE: return "WHILE";
255  15 case DO: return "DO";
256  35 case FOR: return "FOR";
257  14 case BREAK: return "BREAK";
258  8 case CONTINUE: return "CONTINUE";
259  149 case VAR: return "VAR";
260  0 case WITH: return "WITH";
261  22 case CATCH: return "CATCH";
262  86 case EMPTY: return "EMPTY";
263  307 case BLOCK: return "BLOCK";
264  13 case LABEL: return "LABEL";
265  163 case EXPR_RESULT: return "EXPR_RESULT";
266  181 case SCRIPT: return "SCRIPT";
267  6 case GETTER_DEF: return "GETTER_DEF";
268  6 case SETTER_DEF: return "SETTER_DEF";
269  0 case CONST: return "CONST";
270  0 case DEBUGGER: return "DEBUGGER";
271  0 case CAST: return "CAST";
272  0 case ANNOTATION: return "ANNOTATION";
273  0 case PIPE: return "PIPE";
274  0 case STAR: return "STAR";
275  0 case EOC: return "EOC";
276  0 case QMARK: return "QMARK";
277  0 case ELLIPSIS: return "ELLIPSIS";
278  0 case BANG: return "BANG";
279  12 case VOID: return "VOID";
280  0 case EQUALS: return "EQUALS";
281  0 case LB: return "LB";
282  0 case LC: return "LC";
283  0 case COLON: return "COLON";
284    }
285   
286    // Token without name
287  0 throw new IllegalStateException(String.valueOf(token));
288    }
289    }